package com.rest.demo.functional.strean;

import org.apache.commons.lang.math.RandomUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ForkJoinPool;

/**
 * @author Administrator
 * @decription
 * @Date 2018-01-29 16:43
 */
public class StudentStreamDemo {

    public static void main(String[] args) {
        List<Score> score1 = Arrays.asList(new Score("语文", Double.valueOf(RandomUtils.nextInt(100))),new Score("数学", Double.valueOf(RandomUtils.nextInt(100))));
        List<Score> score2 = Arrays.asList(new Score("语文", Double.valueOf(RandomUtils.nextInt(100))),new Score("数学", Double.valueOf(RandomUtils.nextInt(100))));
        List<Score> score3 = Arrays.asList(new Score("语文", Double.valueOf(RandomUtils.nextInt(100))),new Score("数学", Double.valueOf(RandomUtils.nextInt(100))));

        List<Student> stuList = Arrays.asList(new Student("yangbo",score1),new Student("qibing",score2),new Student("yangjia",score3));

        stuList.stream()
                .flatMap(f -> f.getScoreList().stream())
                .forEach(score -> System.out.format("科目：%s;成绩：%s\n",score.getName(),score.getPoint()));

        ForkJoinPool forkJoinPool = ForkJoinPool.commonPool();
        System.out.println(forkJoinPool.getParallelism());
    }
}
